#include"sesja.h"

static struct lista list;


struct sesja *znajdzsesje(const struct sockaddr_storage *adres)
{

    struct lista * head=list;

    while (head)
    {

        if(head->klucz==adres)
            return head;
        head = head->nastepny;

    }

}

void dodajsesje(const struct sockaddr_storage *adres, struct sesja s)
{
    struct lista * head=list;
    struct lista nowa;
    nowa.klucz = adres;
    nowa.wartosc = s;
    nowa.nastepny = NULL;

    while (head)
    {

        if(head->nastepny==NULL)
        head->nastepny=nowa;

        head=head->nastepny;

    }


}

void usunsesje(const struct sockaddr_storage *adres)
{

    struct lista * head=list;

    while (head)
    {

        if(head->nastepny->klucz==adres && head->nastepny->nastepny!=NULL)

        head->nastepny=head->nastepny->nastepny;

        else
        head->nastepny = NULL;

    }

}
